
package com.huizhan.web.dao;
 
import org.springframework.data.domain.*;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
import com.huizhan.web.model.*;
import java.util.*; 


@Repository 
public interface ExhibitorProductDao extends JpaRepository<ExhibitorProduct,Long>
{
    
    /**
     * 根据展商ID获取展品集合
     * @param exhibitorId 展商ID
     * @return 展品集合
     */
    List<ExhibitorProduct> findByExhibitorId(Long exhibitorId);

    /**
     * 分页查展品集合
     * @param name 名称
     * @param remark 描述
     * @param exhibitorId 展商ID
     * @param project_Id 项目ID
     * @param pageable 分页参数
     * @return 展品集合
     */
    @Query(
        value = "SELECT * FROM exhibitor_product"
            + " WHERE (name LIKE CONCAT('%',?1,'%') OR ?1  = '')"
            + " AND (company LIKE CONCAT('%',?2,'%') OR ?2  = '' )"
            + " AND (project_Id =?3 OR ?3  = '') "
            + " AND (exhibitor_Id =?4 OR ?4 = 0 )", 
        countQuery = "SELECT COUNT(1) FROM exhibitor_product"
            + " WHERE (name LIKE CONCAT('%',?1,'%') OR ?1  = '')"
            + " AND (company LIKE CONCAT('%',?2,'%') OR ?2  = '' )"
            + " AND (project_Id =?3 OR ?3  = '') "
            + " AND (exhibitor_Id =?4 OR ?4 = 0 )",
        nativeQuery = true
    )
    Page<ExhibitorProduct> findByWhere(String name,String remark,String project_Id,Long exhibitorId, Pageable  pageable);
}
